"""
    字典： {key:value,key:value 。。。}
    长度：键值对的个数
        key一般是字符串类型 key不能重复
        value可以是任意类型 基本数据类型  高级类型
    字典没有下标

    字典的操作：
        增:添加键值对


"""
user = {"username":"admin","password":"admin123"}

student = {
            "name":"小明",
             "age":20,
            "sex":"男",
            "score":99.8,
            "isHealthy":True,
            "hobby":["足球","篮球","跑步"],
            "teacher":{"name":"李老师","age":40}
}
# 新增
user["status"]="启用"
print(user)
# 修改
user["password"] = "123456"
print(user)
# 删除
del user["status"]
print(user)

username = user.pop("username")
print(username)

# user.clear()
# print(user)

# 通过key获取value
print(user["password"])
print(user.get("username"))
print(user.get("password"))

# 获取所有的key构成的列表
keys = student.keys()
print(keys)
# 获取所有的值构成的列表
values = student.values()
print(values)
# 获取所有键值构成的列表
items = student.items()
print(items)

print(len(student))

for k in keys :
    print(k)
    print(student[k])

for v in values:
    print(v)

for k,v in items:
    print(k,v)

# 统计一串字符串中每一个字符出现的次数HelloWorld
str1 = "HelloWorld"
result = {}
for s in str1:
    result[s] = str1.count(s)
print(result)


# json